
#include <Windows.h>
#include <stdio.h>
#include <time.h>
#include <dos.h>
#include <stdlib.h>
#include <string>
#include "FclientInterface.h"


#define HELP			"help"
#define LISTUSERS		"list"
#define QUIT			"quit"
#define REGISTENEW		"regi "
#define LOGIN			"logi "
#define SENDMESSAGE		"send "
#define RESETPASSWORD	"rpwd "
#define SETCODECTACTICS	"code "


#define MAX_BUF_SIZE 2048


#define SERVERPORT 8820
#define SERVERIP "127.0.0.1"

using namespace std;




class CommandLine{
public:
	CommandLine();
	~CommandLine();

	char* GetCommand(){return gets_s(m_CommandBuf);}
	void ParaeCommandLine(CommandLine* CL);
	void CleanBuf(){memset(m_CommandBuf,0,MAX_BUF_SIZE);}


	void RefreshFriendList(void* fl);
	void ProcessRecvMsg(void* msg);
	void LoginFailed();
	void LoginBusy();
	void NewUser(void* fl);
	void UserLogout(void* fl);
	void SetCodecTacticsSuccessful();
	void SetCodecTacticsFailed();
	void SetPasswordSuccessful();
	void SetPasswordFailed();
	void RegSuccessed(void* f1,void* f2);
	void RegFailed();



private:
	void ConsoleHead();
	void ListHelp();
	void ListUsers();
	void Quit();

	void HandleReg();
	void HandleLogin();
	void HandleSendMsg();
	void HandleResetPassword();
	void HandleSetCodecTactics();

	void GotoXY(int x,int y);
	void GetXY(int* x,int* y);
	void MsgPrint(textMessage* msg);
	
	
	char m_CommandBuf[MAX_BUF_SIZE];
	char m_ID[11];
	bool m_IsInit;
	FriendListElement_t m_FriendList;

};

